﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace BfLib.Sys
{
    public static class ProcessLib
    {
        public static bool Run(string Uri)
        {
            try
            {
                Process.Start(Uri);
            }
            catch
            {
                return false;
            }

            return true;
        }

        public static int RunAndWait(string ProgramFile)
        {
            try
            {
                Process proc = new Process();
                proc.StartInfo.FileName = ProgramFile;
                proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                proc.Start();
                proc.WaitForExit();
                int exitCode = proc.ExitCode;
                proc.Close();

                return exitCode;
            }
            catch
            {
                return -1;
            }

        }
    }
}
